/*
 *	Copyright 2011 andro-inject developers 
 *	Licensed under the Apache License, Version 2.0 (the "License"); 
 *	you may not use this file except in compliance with the License. 
 *	You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 * 
 *	Unless required by applicable law or agreed to in writing, software 
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License. 
 * 
*/

package com.androinject.android;

import android.app.ExpandableListActivity;
import android.os.Bundle;

/**
 * Andro-Inject base class for Android ExpandableListActivity.
 * ManagedExpandableListActivity is a subclass of ExpandableListActivity and provides support for automatic dependency injection.
 * Dependencies are injected within the onCreate() method. Subclasses that override onCreate() have to make 
 * sure that super.onCreate() is called (which should be done anyway). By default the class name is 
 * automatically expanded to a managed component id. <br />
 * For example: If the class is named MyActivity Andro-Inject will look for a managed component definition with 
 * the id 'myActivity' (note that the first letter is written in lower case!).
 * If no automatic resolving of the component id should be used, a managed component id has to be passed as 
 * additional parameter to super.onCreate(..)
 */
public class ManagedExpandableListActivity extends ExpandableListActivity {
	
	/**
	 * Injects dependencies and calls ExpandableListActivity.onCreate().
	 * The class name is automatically expanded to a managed component id 
	 * (e.g. the class name MyActivity will be expanded to the component id 'myActivity').
	 * Calling this method is identical to calling onCreate(savedInstanceState, null)
	 * @param savedInstanceState savedInstanceState Android activity saved instance state
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		this.onCreate(savedInstanceState, null);
	}

	/**
	 * Injects dependencies an calls ExpandableListActivity.onCreate();
	 * The managed component id has to be passed as parameter. Andro-Inject will look for a managed component
	 * definition with the passed id and inject the properties in this activity.
	 * @param savedInstanceState savedInstanceState Android activity saved instance state
	 * @param componentId the managed component id
	 */
	protected void onCreate(Bundle savedInstanceState, String componentId) {
		super.onCreate(savedInstanceState);
		AndroidInitializationHelper.initializeManagedComponent(this, componentId);
	}
	
}
